home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / QuickDraw 3D / Samples / SampleCode / PickOne / sources / PickOne_menu.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-14  |  4.3 KB  |  216 lines  |  [TEXT/CWIE]

  1. /*  menu.c                                                                            
  2.  
  3.     This contains all the menu code.
  4.                                                                                     
  5.     Michael Bishop - August 21 1996                                                    
  6.     Nick Thompson
  7.     (c)1994-96 Apple computer Inc., All Rights Reserved                                
  8.  
  9. */
  10.  
  11. /* --------------------------------------------------------------------
  12. ** Includes
  13. */
  14.  
  15. #include    <StandardFile.h>
  16. #include    <Devices.h>
  17.  
  18. #include    "PickOne_menu.h"
  19. #include    "PickOne_utility.h"
  20. #include    "PickOne_window.h"
  21. #include    "PickOne_document.h"
  22. #include    "PickOne_main.h"
  23.  
  24. #include    "QD3DAcceleration.h"
  25.  
  26.  
  27. /* --------------------------------------------------------------------
  28. ** Global Variables
  29. */
  30.  
  31.  
  32. /* --------------------------------------------------------------------
  33. ** Local Functions
  34. */
  35.  
  36.  
  37. /*    --------------------------------------------------------------------
  38. **    Menu_Adjust
  39. **    Update the menus to reflect the current status of the App
  40. */
  41. void Menu_Adjust( void ) 
  42. {
  43.     DocumentHdl            theDocument;
  44.     MenuHandle            theMenu;
  45.     WindowPtr            theWindow = FrontWindow();
  46.     
  47.     if (theWindow != NULL) {
  48.     
  49.         theDocument = Window_GetDocument(theWindow);
  50.  
  51.         if(theDocument != NULL)    {
  52.  
  53.             
  54.             /*    Renderer Menu    */
  55.             {
  56.                 long    theVendorID, theEngineID;
  57.                 
  58.                 Document_GetRendererPreferences(theDocument, &theVendorID, &theEngineID);
  59.                 
  60.                 theMenu = GetMenuHandle(mRenderer);
  61.  
  62.                 if (theVendorID == kQAVendor_BestChoice)
  63.                 {
  64.                     CheckItem(theMenu, iBest, true);
  65.                 }
  66.                 else
  67.                 {
  68.                     CheckItem(theMenu, iBest, false);
  69.                 }
  70.  
  71.                 if (theEngineID == kQAEngine_AppleHW)
  72.                     CheckItem(theMenu, iHardware, true);
  73.                 else
  74.                     CheckItem(theMenu, iHardware, false);
  75.  
  76.                 if (theEngineID == kQAEngine_AppleSW)
  77.                     CheckItem(theMenu, iSoftware, true);
  78.                 else
  79.                     CheckItem(theMenu, iSoftware, false);
  80.             }
  81.         }
  82.     }
  83. }
  84.  
  85.  
  86. /*    --------------------------------------------------------------------
  87. **    Menu_HandleCommand
  88. **    Finds out what was selected and does something about it.
  89. */
  90. void Menu_HandleCommand(long menuResult)
  91. {
  92.     short                menuID;
  93.     short                menuItem;
  94.     Str255                daName;
  95.     MenuHandle            theMenu;
  96.     
  97.     DocumentHdl            theDocument;
  98.  
  99.     short                numTypes = 1 ;
  100.     SFTypeList            myTypes = { '3DMF', 0 } ;
  101.     
  102.  
  103.     WindowPtr            theWindow = FrontWindow() ;
  104.             
  105.     theDocument = Window_GetDocument(theWindow);
  106.  
  107.     menuID = Utility_HiWrd(menuResult);
  108.     menuItem = Utility_LoWrd(menuResult);
  109.     
  110.     switch ( menuID ) {
  111.         /*  */
  112.         /* --------------------------------------------------------------------------     */
  113.         /*  */
  114.         case mApple:
  115.             switch ( menuItem ) {
  116.  
  117.                 case iAbout:
  118.                     Main_DoAbout() ;    
  119.                     break ;
  120.                                 
  121.                 default:
  122.                     GetMenuItemText(GetMenuHandle(mApple), menuItem, daName);
  123.                     (void) OpenDeskAcc(daName);
  124.                     break;
  125.             }
  126.             break;
  127.         /* --------------------------------------------------------------------------     */
  128.         case mFile:
  129.             switch ( menuItem ) {
  130.             
  131.                 case iNew:
  132.                     Document_New() ;
  133.                     break ;
  134.                 
  135.                 case iOpen:
  136.                     Document_Open(Document_New()) ;
  137.                     break ;
  138.  
  139.                 case iSave:    
  140.                     Document_Save( Window_GetDocument(theWindow) ) ;
  141.                     break ;
  142.                 
  143.                 case iSaveAs:
  144.                     break;                
  145.                 
  146.                 case iClose:
  147.                     Document_Dispose( Window_GetDocument(theWindow) ) ;
  148.                     break ;
  149.                     
  150.                 case iQuit:
  151.                     gQuitFlag = true ;
  152.                     break;
  153.             }
  154.             break;
  155.             
  156.             
  157.         /* --------------------------------------------------------------------------     */
  158.         case mEdit:
  159.  
  160.             switch(menuItem)
  161.             {
  162.                 case iCut:
  163.                     break;
  164.                 case iCopy:
  165.                     break;
  166.                 case iPaste:
  167.                     break;
  168.                 case iClear:
  169.                     break;
  170.                 default:
  171.                     break;
  172.             }
  173.             break; 
  174.  
  175.         /* --------------------------------------------------------------------------     */
  176.         case mRenderer:
  177.  
  178.         if (theWindow != NULL)
  179.         {
  180.             long    theVendorID, theEngineID;
  181.             Document_GetRendererPreferences(theDocument, &theVendorID, &theEngineID);
  182.                 
  183.             theMenu = GetMenuHandle(mRenderer);
  184.             
  185.             switch(menuItem)
  186.                 {
  187.                     case iSoftware:
  188.                         theEngineID = kQAEngine_AppleSW;
  189.                         break;
  190.                     case iHardware:
  191.                         theEngineID = kQAEngine_AppleHW;
  192.                         break;
  193.                     case iBest:
  194.                     if ( theVendorID == kQAVendor_Apple)
  195.                         theVendorID = kQAVendor_BestChoice;
  196.                     else
  197.                         theVendorID = kQAVendor_Apple;
  198.                         break;
  199.                     default:
  200.                         break;
  201.                 }
  202.  
  203.             Document_SetRendererPreferences(theDocument, theVendorID, theEngineID);
  204.  
  205.             HLock((Handle)theDocument);
  206.             Document_Draw(*theDocument);
  207.             HUnlock((Handle)theDocument);
  208.         }
  209.         break; 
  210.  
  211.     }
  212.     HiliteMenu(0);        /*  Unhighlight whatever MenuSelect or MenuKey hilited */
  213. }
  214.  
  215.  
  216.